package com.situ.day15home;

import java.util.Scanner;

import org.junit.Test;

public class HomeWork {
	@Test
	public void test1() {
		String str = "12321";
		char[] array = str.toCharArray();
		boolean isHuiWen = true;
		for (int i = 0; i < array.length / 2; i++) {
			if (array[i] != array[array.length-i-1]) {
				isHuiWen = false;
				break;
			}
		}
		if (isHuiWen = true) {
			System.out.println("是回文数");
		}else {
			System.out.println("不是回文数");
		}
	}
	@Test
	public void test2() {
		System.out.println("请输入一行字符");
		Scanner scanner = new Scanner(System.in);
		String str = scanner.nextLine();
		char[] array = str.toCharArray();
		int abc = 0;
		int number = 0;
		int blank = 0;
		int other = 0;
		for (int i = 0; i < array.length; i++) {
			char ch = array[i];
			if (ch >= 'a' && ch <= 'z') {
				abc++;
			}else if (ch >= 0 && ch <= 9) {
				number++;
			}else if (ch == ' ') {
				blank++;
			}else {
				other++;
			}
		}
		System.out.println("字母个数是" + abc);
		System.out.println("数字个数是" + number);
		System.out.println("空格个数是" + blank);
		System.out.println("其余个数是" + other);
	}
	@Test
	public void test3() {
		Scanner scanner = new Scanner(System.in);
		System.out.println("请输入x的值");
		int x = scanner.nextInt();
		System.out.println("请输入y的值");
		int y = scanner.nextInt();
		System.out.println("请输入z的值");
		int z = scanner.nextInt();
		if (x > y) {
			int temp = x;
			x = y;
			y = temp;
		}
		if (x > z) {
			int temp = x;
			x = z;
			z = temp;
		}
		if (y > z) {
			int temp = y;
			y = z;
			z = temp;
		}
		System.out.println("x:" + x);
		System.out.println("y:" + y);
		System.out.println("z:" + z);
	}
	@Test
	public void test4() {
		int[] score={0,0,1,2,3,5,4,5,2,8,7,6,9,5,4,8,3,1,0,2,4,8,7,9,5,2,1,2,3,9};
		int[] countArray = new int[10];
		for (int i = 0; i < score.length; i++) {
			switch (score[i]) {
			case 0:
				countArray[0]++;
				break;
			case 1:
				countArray[1]++;
				break;
			case 2:
				countArray[2]++;
				break;
			case 3:
				countArray[3]++;
				break;
			case 4:
				countArray[4]++;
				break;
			case 5:
				countArray[5]++;
				break;
			case 6:
				countArray[6]++;
				break;
			case 7:
				countArray[7]++;
				break;
			case 8:
				countArray[8]++;
				break;
			case 9:
				countArray[9]++;
				break;
			default:
				System.out.println("default: " + score[i]);
				break;
			}
			for (int j = 0; j < countArray.length; j++) {
				System.out.println(j + "出现的次数是" + countArray[j]);
			}
		}
	}

}
